package com.vca.admin.controller;


import com.alibaba.fastjson.JSONObject;
import com.vca.common.page.CommonPage;
import com.vca.common.request.*;
import com.vca.common.response.GiftCardResponse;
import com.vca.common.response.sf.ResponseCancel;
import com.vca.common.response.sf.RoutePushResponse;
import com.vca.common.result.CommonResult;
import com.vca.service.service.SFService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("api/admin/sf")
@Api(tags = "发货")
public class SendContrller {

    @Autowired
    private SFService sfService;

//    @ApiOperation("发货下单")
//    @RequestMapping(value = "/place", method = RequestMethod.POST)
//    public CommonResult<ResponseCancel> findTable(@RequestBody @Validated StoreOrderSendRequest request) {
//        return CommonResult.success(sfService.sendSF(request));
//    }


    @ApiOperation("下单结果查询")
    @RequestMapping(value = "/result", method = RequestMethod.GET)
    public CommonResult<ResponseCancel> OrderResults(String orderId) {
        return CommonResult.success(sfService.getOrderResult(orderId));
    }


    @ApiOperation("取消发货")
    @RequestMapping(value = "/cancel", method = RequestMethod.POST)
    public CommonResult<ResponseCancel> cancelSend(String orderId) {
        return CommonResult.success(sfService.cancelSF(orderId));
    }


    @ApiOperation("下单路由查询")
    @RequestMapping(value = "/routing", method = RequestMethod.GET)
    public CommonResult<ResponseCancel> OrderRouting(
                                                     @RequestParam(value = "orderNo") String orderNo,
                                                     @ApiParam(value = "2退货物流 1=发货物流")
                                                     @RequestParam(value = "type") Integer type) {
        return CommonResult.success(sfService.getOrderRouting("",orderNo,type));
    }


    @ApiOperation(value = "路由推送")
    @RequestMapping(value = "/route/push", method = RequestMethod.POST)
    public RoutePushResponse RoutePush(@RequestBody Body Body) {
        return sfService.getRoutePush(Body);
    }


}
